//package it.univpm.dii.tressette.ui;
//
//import it.univpm.dii.tressette.R;
//import android.app.Activity;
//import android.os.Bundle;
//import android.view.View;
//import android.view.View.OnClickListener;
//import android.widget.Button;
//import android.widget.ImageButton;
//import android.widget.RelativeLayout;
//import android.widget.RelativeLayout.LayoutParams;
//
//public class TressetteTestActivity extends Activity{
//	public RelativeLayout myRelative;
//	public Button myAdd;
//	private int[] myCards={101,102,103,105,108};
//	@Override
//	public void onCreate(Bundle savedInstanceState){
//		super.onCreate(savedInstanceState);
//		this.setContentView(R.layout.main);
//		myAdd=(Button)this.findViewById(R.id.my_add);
//		myAdd.setOnClickListener(new OnClickListener() {
//			
//			public void onClick(View arg0) {
//				// TODO Auto-generated method stub		
//				refreshMyRelativeLayout();
//			}
//		});
//		myRelative=(RelativeLayout)this.findViewById(R.id.my_relative);
//		for(int i=0;i<myCards.length;i++){
//			ImageButton btn=new ImageButton(this.getApplicationContext());
//			btn.setImageResource(R.drawable.ic_launcher);
//			btn.setId(myCards[i]);
//			btn.setOnClickListener(new OnClickListener(){
//
//				public void onClick(View arg0) {
//					LayoutParams lp=(LayoutParams) arg0.getLayoutParams();
//					lp.topMargin-=10;
//					arg0.setLayoutParams(lp);
//					refreshMyRelativeLayout();
//				}
//				
//			});
//			LayoutParams lp=new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
//			int margin=myRelative.getWidth() / (1+myRelative.getChildCount());
//			lp.leftMargin=i*margin;
//			btn.setLayoutParams(lp);
//			myRelative.addView(btn,lp);
//		}
//		refreshMyRelativeLayout();
//	}
//	
//	public void refreshMyRelativeLayout() {
//		if (myRelative.getChildCount() != 0) {
//			int margin = myRelative.getWidth() / myRelative.getChildCount();
//			for (int i = 0; i < myRelative.getChildCount(); i++) {
//				//RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
//				//lp.setMargins(margin * i, 0, 0, 0);
//				LayoutParams lp= (LayoutParams)myRelative.getChildAt(i).getLayoutParams();
//				lp.leftMargin=margin*i;
//				myRelative.getChildAt(i).setLayoutParams(lp);
//			}
//		}
//	}
//}
//package it.univpm.dii.tressette.ui;
//
//import android.app.Activity;
//import android.os.Bundle;
//import android.view.View;
//import android.view.View.OnClickListener;
//import android.widget.Button;
//import android.widget.RelativeLayout;
//
//public class TressetteTestActivity extends Activity {
//	private final int baseId = 1048637;
//	public RelativeLayout myRelative;
//	public Button myAdd;
//	public Button myReset;
//	public RelativeLayout.LayoutParams lp;
//	public int n;
//
//	@Override
//	public void onCreate(Bundle savedInstanceState) {
//		super.onCreate(savedInstanceState);
//		this.setContentView(it.univpm.dii.tressette.R.layout.main);
//		n = 0;
//		myRelative = (RelativeLayout) this
//				.findViewById(it.univpm.dii.tressette.R.id.my_relative);
//		myReset = (Button) this
//				.findViewById(it.univpm.dii.tressette.R.id.my_delete);
//		myReset.setOnClickListener(new OnClickListener() {
//
//			public void onClick(View arg0) {
//
//				myRelative.removeAllViews();
//				n = 0;
//				refreshMyRelativeLayout();
//			}
//
//		});
//		myAdd = (Button) this.findViewById(it.univpm.dii.tressette.R.id.my_add);
//		myAdd.setOnClickListener(new OnClickListener() {
//
//			public void onClick(View arg0) {
//				Button btn = new Button(myRelative.getContext());
//				btn.setText(Integer.toString(n));
//				int id = Integer.valueOf(Integer.toString(baseId)
//						+ Integer.toString(n));
//				btn.setId(id);
//				btn.setOnClickListener(new OnClickListener() {
//
//					public void onClick(View arg0) {
//						myRelative.removeView(arg0);
//						refreshMyRelativeLayout();
//					}
//
//				});
//				myRelative.addView(btn);
//				refreshMyRelativeLayout();
//				n++;
//			}
//
//		});
//		myReset = (Button) this
//				.findViewById(it.univpm.dii.tressette.R.id.my_delete);
//
//	}
//
//	public void refreshMyRelativeLayout() {
//		if (myRelative.getChildCount() != 0) {
//			int margin = myRelative.getWidth() / myRelative.getChildCount();
//			for (int i = 0; i < myRelative.getChildCount(); i++) {
//				lp = new RelativeLayout.LayoutParams(
//						60,
//						RelativeLayout.LayoutParams.WRAP_CONTENT);
//				lp.setMargins(margin * i, 0, 0, 0);
//				myRelative.getChildAt(i).setLayoutParams(lp);
//			}
//		}
//	}
//
//}
